(function (lib, config) {
    var loadFunc = function () {
        var textAry = config.words.split('|'), bgcolorAry = config.bgcolor.split('|'), textcolorAry = config.textcolor.split('|'), imglinkAry = config.imglink.split('|'), weblinkAry = config.weblink.split('|'), identifier = config.identifier.split('|');
        identifier[0] = identifier[0] || 'swt_quanping';
        textAry[0] = textAry[0] || '益阳男科咨询中心';
        textAry[1] = textAry[1] || '0737-3800888';
        textAry[2] = textAry[2] || '益阳市医保定点医院  北京大学人民医院专家指导医院 张晓威博士领衔三甲男科专家团坐诊   益阳市医保定点医院  北京大学人民医院专家指导医院 张晓威博士领衔三甲男科专家团坐诊';
        textAry[3] = textAry[3] || '你好,我是益阳九龙特邀专家张晓威,你是想咨询';
        textAry[4] = textAry[4] || '方面的内容吗？';
        textAry[5] = textAry[5] || '我有20年男科常见病、多发症问诊经验，说说你的情况，我一定可以帮到你。';
        imglinkAry[0] = imglinkAry[0] || 'http://nkm.yyjl120.com/swt/zjswtpic/banner1.jpg';
        imglinkAry[1] = imglinkAry[1] || 'http://nkm.yyjl120.com/swt/zjswtpic/new_qpswt2.jpg';
        imglinkAry[2] = imglinkAry[2] || 'http://nkm.yyjl120.com/swt/zjswtpic/new_qpswt3.gif';
        bgcolorAry[0] = bgcolorAry[0] || '#0284c2';
        bgcolorAry[1] = bgcolorAry[1] || '#f5f5f5';
        bgcolorAry[2] = bgcolorAry[2] || '#9de983';
        textcolorAry[0] = textcolorAry[0] || '#fff';
        textcolorAry[1] = textcolorAry[1] || '';
        textcolorAry[2] = textcolorAry[2] || '#333';
        textcolorAry[3] = textcolorAry[3] || '#333';
        textcolorAry[4] = textcolorAry[4] || '#333';
        textcolorAry[5] = textcolorAry[5] || '#222';
        /*TODO 方法*/
        function getscrollTop() {
            var scrollTop = 0;
            if (document.documentElement && document.documentElement.scrollTop) {
                return document.documentElement.scrollTop;
            }
            if (document.body.scrollTop) {
                return document.body.scrollTop;
            }

        }
        function getClientHeight() {
            var clientHeight = 0;
            if (document.body.clientHeight && document.documentElement.clientHeight) {
                var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
            }
            else {
                var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight;
            }
            return clientHeight;
        }

        var _ua = navigator.userAgent, _ua_text = false, _position = "fixed";
        if (config.iscomapp==1 && _ua.indexOf('baiduboxapp') > -1) {
            _ua_text = true; _position = "absolute";
        }
        var strVar = [];
        strVar.push("<style>");
        strVar.push("@-webkit-keyframes marquee {");
        strVar.push("    0% { left: 0; }");
        strVar.push("    100% { left: -100%; }");
        strVar.push("}");
        strVar.push("@-moz-keyframes marquee {");
        strVar.push("    0% { left: 0; }");
        strVar.push("    100% { left: -100%; }");
        strVar.push("}");
        strVar.push("@-ms-keyframes marquee {");
        strVar.push("    0% { left: 0; }");
        strVar.push("    100% { left: -100%; }");
        strVar.push("}");
        strVar.push("@-o-keyframes marquee {");
        strVar.push("    0% { left: 0; }");
        strVar.push("    100% { left: -100%; }");
        strVar.push("}");
        strVar.push("@keyframes marquee {");
        strVar.push("  0%{left:0}");
        strVar.push("  100%{left: -100%}");
        strVar.push("}");
        strVar.push(".flagBox{position:fixed;z-index:3000000000;top:0;width:100%;height:100%;-webkit-transition:all 8s ease;-o-transition:all 8s ease;transition:all 8s ease;overflow-y: auto; visibility:hidden;}");
        strVar.push(".swt_fcenter{ width:100%;max-width: 640px; margin:0 auto; background:" + bgcolorAry[1] + ";overflow: auto;position:fixed; right:0; left:0; top:0; bottom:0;  }");
        strVar.push(".swtqp_div1{ width:100%; margin:0 auto;background:" + bgcolorAry[0] + "; padding:1% 3%; font-size:26px; color:" + textcolorAry[0] + "; text-align:center;position: fixed;max-width: 640px;  z-index:99999;font-weight: bold;line-height: 40px;box-sizing: border-box;}");
        strVar.push(".swtqp_div1 a{font-size:20px;color:#fff; width:15%; float:left; margin-top:1%;line-height: 33px;}");
        strVar.push(".swtqp_div1 a i{ width:35px; height:40px; float:left; background:url(http://nkm.yyjl120.com/swt/zjswtpic/swt_dbtbs1.png) no-repeat 73% 0%; background-size:285% 100%; margin-right:6%;}");
        strVar.push(".swtqp_div1 a:nth-child(2) i{ background-position:3% 0%;  background-size:285% 100%; }");
        strVar.push(".swtqp_div1 a:nth-child(2){ width:9%; float:right;}");
        strVar.push(".swtqp_div2{ width:100%; height:auto; overflow:hidden; margin:1% auto 0%; text-align:center;}");
        strVar.push(".swtqp_div2 img:nth-child(2){ margin-top:6%;}");
        strVar.push(".swtqp_div2 img{ width:100%;}");
        strVar.push(".swtqp_div3s{ width: 100%; height: auto;overflow:hidden; margin-top:12.5%; background:#f3f3f3; padding:0 0% 0 4%; box-sizing: border-box;}");
        strVar.push(".swtqp_div3s .scroll_gg{ padding:0;}");
        strVar.push(".swtqp_div3s div{ padding:0 3%;height:40px;box-sizing: border-box;}");
        strVar.push(".swtqp_div3s .scroll_gg1{ padding:2% 0;}");
        strVar.push(".swtqp_div3s div:nth-child(2) div:nth-child(2){ padding:0;}");
        strVar.push(".swtqp_div3s div{  font-size:22px; padding:0;color:#333333;margin: 0;font-weight:bold; }");
        strVar.push(".swtqp_div3s h3{ width:100%; margin:0 auto; font-size:22px; font-weight:normal;font-weight:bold;color:" + textcolorAry[2]+ "; padding-top: 1%; }");
        strVar.push(".scroll_gg div{ line-height: 50px;}");
        strVar.push(".swtqp_div3{ width:100%; height:auto; overflow:hidden;padding: 9% 4% 23%;box-sizing: border-box;}");
        strVar.push(".swtqp_div3 a{ width:100%; float:left;}");
        strVar.push(".swtqp_div3 a b{ color:" + '#cc0000' + "; font-weight:normal;}");
        strVar.push(".swtqp_div3 a img{ float:left; margin-right:4%;}");
        strVar.push(".swtqp_div3 p{ box-sizing: border-box;width:82%; float:left; line-height:40px; font-size:24px; color:" + textcolorAry[5] + "; position:relative; padding: 2% 3% 3% 3%;border-radius: 10px; border:1px solid #88d56d; background:" + bgcolorAry[2] + "; }");
        strVar.push(".swtqp_div3 p:before{ content:\'\'; width:17px; height:29px;left:-3.5%; top:20%; background:url(http://nkm.yyjl120.com/swt/zjswtpic/swt_qpsj.png) no-repeat; position: absolute; background-size:100%;}");
        strVar.push(".swtqp_div3 a:nth-child(2){ margin-top:6%;}");
        strVar.push(".marquee{ overflow: hidden;position: relative;} ");
        strVar.push(".marquee div h3{display: block;width: 200%; position: absolute;overflow: hidden;  -webkit-animation: marquee 13s linear infinite; -moz-animation: marquee 13s linear infinite; -ms-animation: marquee 13s linear infinite;-o-animation: marquee 13s linear infinite;animation: marquee 13s linear infinite;}");
        strVar.push(".swtqp_div4{ max-width: 640px; width:100%;height:auto; overflow:hidden; margin:2% auto 0%; position:" + _position + "!important;bottom: 0;}");
        strVar.push(".swtqp_div4 a{width: 100%;text-align: center;display: block;}");
        strVar.push(".swtqp_div4 a img{width: 100%;display: block;}");
        strVar.push("@media screen and (max-width:638px) and (min-width:480px){");
        strVar.push(".swtqp_div1 a{ font-size:16px;}");
        strVar.push(".swtqp_div1 a i{ width:29px; height:33px; margin-right: 3%;}");
        strVar.push(".swtqp_div1{ font-size:21px; padding: 2.5% 3%;line-height: 35px;}");
        strVar.push(".swtqp_div3 p:before{left: -4.5%;}");
        strVar.push(".swtqp_div3 p{ font-size:18px; line-height:33px;}");
        strVar.push(".swtqp_div3 a img{ width:14%;}");
        strVar.push(".swtqp_div3s h3{ padding-top: 2%;}");
        strVar.push("}");
        strVar.push("@media screen and (max-width: 479px) and (min-width: 319px){");
        strVar.push(".swtqp_div1{ font-size:17px;line-height: 29px;}");
        strVar.push(".swtqp_div1 a{width: 19%; font-size:14px;line-height: 24px;}");
        strVar.push(".swtqp_div1 a i{ width:25px; height:28px;}");
        strVar.push(".swtqp_div3s h3{font-size: 16px;}");
        strVar.push(".scroll_gg div{ line-height: 35px;}");
        strVar.push(".swtqp_div3s div{  height: 33px;}");
        strVar.push(".swtqp_div3 a img{ width:14%;}");
        strVar.push(".swtqp_div3 p,.swtqp_div3 a:nth-child(2) p{ font-size:12px; line-height:21px; }");
        strVar.push(".swtqp_div3 p:before{ width:10px; height:15px; left: -4.0%;}");
        strVar.push(".swtqp_div3{ padding:10% 4% 0%;}");
        strVar.push(".swtqp_div3s h3{ padding-top: 2%;}");
        strVar.push("}");
        strVar.push("@media screen and (max-width:414px) and (min-width:380px){");
        strVar.push(".swtqp_div3 p, .swtqp_div3 a:nth-child(2) p{ font-size:15px; line-height:30px;}");
        strVar.push(".swtqp_div3 p:before{width: 12px;height: 18px; }");
        strVar.push(".swtqp_div1 a{ width: 17%;font-size: 16px;}");
        strVar.push(".swtqp_div1 a:nth-child(2){ width:7%;}");
        strVar.push(".swtqp_div3s{margin-top: 11.0%;}");
        strVar.push("}");
        strVar.push("@media screen and (max-width:380px) and (min-width:360px){");
        strVar.push(".swtqp_div3 p, .swtqp_div3 a:nth-child(2) p{font-size:13px; line-height:25px;}");
        strVar.push(".swtqp_div3 p:before{width: 12px;height: 18px; }");
        strVar.push(".swtqp_div1 a{width: 17.5%;font-size: 15px;}");
        strVar.push(".swtqp_div1 a:nth-child(2){ width:7%;}");
        strVar.push(".swtqp_div3s h3{ padding-top: 1.5%;}");
        strVar.push("}");
        strVar.push("</style>");
        strVar.push("<div class=\'flagBox\' id=\'flagBox\'>");
        strVar.push("  <div class=\'swt_fcenter\' id=\'swt_fcenter\'>");
        strVar.push("    <div class=\'swtqp_div1\'> <a onclick=\'swt_center_nswt();\'><i></i>返回</a> " + textAry[0] + " <a href=\'tel:" + textAry[1] + "\'><i></i></a> </div>");
        strVar.push("    <div class=\'swtqp_div3s\'>");
        strVar.push("    <div class=\'marquee\'>");
        strVar.push("            <div style=\'width:100%;overflow:hidden; white-space: nowrap;margin:0 auto; padding:0;\'>");
        strVar.push("            <h3>" + textAry[2] + "</h3>");
        strVar.push("       </div>");
        strVar.push(" </div>");
        strVar.push(" </div>");
        strVar.push("    <div class=\'swtqp_div2\' onClick=\'openZoosUrl(\"" + identifier[0] + "\")\'> <img src=\'" + imglinkAry[0] + "\'> </div>");
        strVar.push("");
        strVar.push("    <div class=\'swtqp_div3\' > <a href=\'javascript:void(0);\' onclick=\'openZoosUrl(\"" + identifier[0] + "\")\' id=\'hycq_dhk01\' style=\'display:none;\'> <img src=\'" + imglinkAry[1] + "\' class=\'swtpb_t\'>");
        strVar.push("      <p><span style='color:"+textcolorAry[3]+";'>" + textAry[3] + "<span><b id=\'rl_dhlist1\'>男科疾病</b><span style='color:"+textcolorAry[4]+";'>" + textAry[4] + "</span></p>");
        strVar.push("      </a> <a href=\'javascript:void(0);\' onclick=\'openZoosUrl(\"" + identifier[0] + "\")\' id=\'hycq_dhk02\' style=\'display:none;\'><img src=\'" + imglinkAry[1] + "\' class=\'swtpb_t\'>");
        strVar.push("      <p>" + textAry[5] + "</p>");
        strVar.push("      </a> </div>");
        strVar.push("       <div class=\'swtqp_div4\' id=\'swtqp_div4\' style=\'bottom:0%;\'> <a href=\'javascript:void(0);\' onClick=\'openZoosUrl(\"" + identifier[0] + "\")\'> <img src=\'" + imglinkAry[2] + "\' class=\'swtpb_t\'></a>");
        strVar.push("      </div>");
        strVar.push("</div>");
        strVar.push("</div>");
        strVar.push("");
        var o = document.createElement('div');
        o.innerHTML = strVar.join('');
        while (o.firstElementChild) {
            document.body.appendChild(o.firstElementChild);
        };

        function addEvent(obj, type, fn) {
            if (obj.attachEvent) {
                obj.attachEvent('on' + type, function () {
                    fn.call(obj);
                })
            } else {
                obj.addEventListener(type, fn, false);
            }
        }


        if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
            window.setTimeout(showDiv, config.firsttime * 1000);
        }
        var _scrollset = 0;
        function showDiv() {
            document.getElementById('flagBox').style.visibility = 'visible';
            document.getElementById('flagBox').style.display = 'block';
            var hycq_dhk01 = document.getElementById("hycq_dhk01");
            var hycq_dhk02 = document.getElementById("hycq_dhk02");
            setTimeout(stoolshow, 0);
            function stoolshow() { setTimeout(stoolshow2, 0); }
            function stoolshow2() { hycq_dhk01.style.display = "block"; setTimeout(stoolshow3, 3000); }
            function stoolshow3() { hycq_dhk02.style.display = "block"; }
            history.pushState({ lzjt: 1 }, "", "#com");
            _scrollset = 1;
        }

        swt_center_nswt = function () {
            document.getElementById('flagBox').style.display = 'none';
            document.getElementById('flagBox').style.visibility = 'hidden';
            _scrollset = 0;
            window.setTimeout(showDiv, config.relapsetime * 1000);
            history.replaceState(null, '', location.pathname + location.search);

        }

        window.addEventListener('hashchange', function () {
            swt_center_nswt();
        });





        // 调用方法
        (function () {
            var r = document.referrer, swtqp_div3 = document.querySelector('.swtqp_div3').getElementsByTagName('a')[0].getElementsByTagName('p')[0];
            var _ds = document.querySelector('.swtqp_div3').getElementsByTagName('a'), d1 = _ds[0], d2 = _ds[1];
            setTimeout(function () {
                d1.style.visibility = 'visible';
                setTimeout(function () {
                    window.scroll(0, d2.offsetHeight);
                    d2.style.visibility = 'visible';
                }, 2000)
            }, 1000);

            var keyfun = function (a) {
                if (a == "" || a == null) { return ""; }
                var refer = a;
                var sosuo = refer.split(".")[1];
                var grep = null;
                var str = null;
                var keyword = null;
                switch (sosuo) {
                    case "baidu":
                        refer += '&';
                        grep = /word\=.*\&/i;
                        str = refer.match(grep);
                        if (str != null) {
                            keyword = str.toString().split("=")[1].split("&")[0];
                            return decodeURIComponent(keyword);
                        }
                        break;
                    case "sogou":
                        grep = /keyword\=.*\&/i;
                        str = refer.match(grep);
                        if (str != null) {
                            keyword = str.toString().split("=")[1].split("&")[0];
                            return decodeURIComponent(keyword);
                        }
                        break;
                    case "sm":
                    case "m":
                        if (refer.indexOf('sm') > -1) {
                            refer = refer.replace('?q=', '?&q=');
                            grep = /&q\=.*\&/i;
                            str = refer.match(grep);
                            if (str != null) {
                                keyword = str.toString().split("&")[1].split("=")[1];
                                return decodeURIComponent(keyword);
                            }
                        }
                        break;
                }
                return '';
            }
            var key_title_text = keyfun(r), key_fk_tjfs = '';

            if (swtqp_div3 != null) {
                if (key_title_text != '') {
                    swtqp_div3.innerHTML = '' + textAry[3] + '【<b style="color: #bb1a1a;font-weight: bolder;">' + key_title_text + '</b>】' + textAry[4] + '';
                    key_fk_tjfs = encodeURIComponent('||key:' + key_title_text);
                }
            }

        })();

        if (_ua_text) {
            var _t_swtqp_div4 = document.getElementById('swtqp_div4').style.bottom;
            if (_t_swtqp_div4 == '') { _t_swtqp_div4 = 0; }
            addEvent(window, 'scroll', function () {
                document.getElementById('swtqp_div4').style.bottom = parseInt(_t_swtqp_div4) - (getScrollTop() / getClientHeight()) * 100 + '%';

            })

        }
    };
    lib.load(loadFunc);/*执行代码*/
})('{{lib}}', '{{config}}');